package com.nand.module.function.adapter;

import android.view.View;
import android.view.ViewGroup;

import androidx.viewpager.widget.PagerAdapter;

import java.util.ArrayList;

/**
 * @author wangjt
 * @date 2018/5/22
 */
public class PhotoWallAdapter extends PagerAdapter {

    private ArrayList<View> mData;

    public PhotoWallAdapter(ArrayList<View> data) {
        if(data == null){
            mData=new ArrayList<>();
        }else{
            mData=data;
        }
    }

    @Override
    public int getCount() {
        return mData.size();
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        container.addView(mData.get(position));
        return mData.get(position);
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView(mData.get(position));
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }
}
